package com.yj.oa.mapper;

import com.yj.oa.entity.system.OAUserInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/**
 * Copyright 2017 (C) Yunjian-VC
 * Created on : 2017/12/7
 * Author     : Unbelievable9
 **/
@Repository
@Mapper
public interface OAUserInfoMapper {

    @Insert("INSERT INTO oa_user_info " +
            "(user_id, username, phone, role_level, firm, bd, bu, corp) " +
            "VALUES(#{item.user_id}, #{item.username}, #{item.phone}," +
            " #{item.role_level}, #{item.firm}, #{item.bd}, #{item.bu}, #{item.corp}) " +
            "ON DUPLICATE KEY " +
            "UPDATE user_id = #{item.user_id}, username = #{item.username}, " +
            "phone = #{item.phone}, role_level = #{item.role_level}, firm = #{item.firm}, " +
            "bd = #{item.bd}, bu = #{item.bu}, corp = #{item.corp}")
    void insert(@Param("item") OAUserInfo item);

    @Select("select * from oa_user_info where user_id=#{user_id} limit 1")
    OAUserInfo getOAUserInfoByUserId(@Param("user_id") String user_id);
}
